<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1,minimum-scale=1,user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <link rel="stylesheet" type="text/css" href="/public/static/wx/css/base.css" />
    <link rel="stylesheet" type="text/css" href="/public/static/wx/font/font-awesome-4.7.0/css/font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="/public/static/wx/css/rent-list.css" />
    <script src="/public/static/wx/js/flex.js" type="text/javascript" charset="utf-8"></script>
    <title>出借列表</title>
    <style>
        .vers{
            color: red;
            display: block;
            text-align: center;
            line-height: 45px;
            border: 1px solid;
            border-radius: 4px;
        }
        .layui-layer-btn a{
            font-size: 18px;
        }
        .layui-layer-content{
            font-size: 17px;
        }
    </style>
</head>

<body>
<div class="index">
    <div class="topbar">
        <a href="javascript:history.go(-1);"><i class="fa fa-angle-left"></i></a>
        <p>出借列表</p>
    </div>
    <div class="rent-list">
        <ul class="title clearfix">
            <li>出借人</li>
            <li>借用人</li>
            <li>出借时间</li>
            <li>审核</li>
        </ul>
        <div id="dataList">
            <!--<div class="rent-item">
                <ul class="clearfix">
                    <li>王凤山</li>
                    <li>李雪梅</li>
                    <li>2018-07-26</li>
                    <li class="uncheck">未审核</li>
                </ul>
                <p>备注：解放路快速减肥是老年妇女建瓯市附近</p>
            </div>-->

        </div>



    </div>
</div>

<script src="/public/static/wx/js/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/public/static/wx/plug-in/layui/layui.all.js" type="text/javascript" charset="utf-8"></script>
<script>
    var A_obj = {
        page:1,
        limit:10,
        per:2,
    };

    var url = '{:url("queryLend")}';


    $.post(url,A_obj,call);

    function call(data) {
        var dom = $('<div class="rent-item" onclick="jup(this)">\n' +
            '                <ul class="clearfix">\n' +
            '                    <li class="out_name"></li>\n' +
            '                    <li class="input_name"></li>\n' +
            '                    <li class="time"></li>\n' +
            '                    <li class="ver"></li>\n' +
            '                </ul>\n' +
            '                <p class="desc"></p>\n' +
            '            </div>');

        A_obj.per = Math.ceil(data.count/A_obj.limit);
        $('#dataList').empty();
        $.each(data.data,function (k,v) {
            var ts = dom.clone();
            ts.find('.out_name').text(v.out_name);
            ts.find('.input_name').text(v.input_name);
            ts.find('.time').text(v.lend_time);
            ts.find('.desc').text('备注：'+v.desc);

            if(v.state_id == 43){
                ts.find('.ver').html('<span style="color: red">'+v.state_name+'</span>');
            }else{
                if(v.is_ver==1){
                    ts.find('.ver').html('<span style="color: green">已审核</span>');
                }else{
                    ts.find('.ver').html('<span class="vers" style="color: red" onclick="ver(event,this)" did="'+v.id+'">未审核</span>');
                }
            }

            if(v.state_id == 42 || v.state_id == 41){
                ts.find('.ver').html('<span style="color: green">'+v.state_name+'</span>');
            }

            ts.attr('did',v.id);

            $('#dataList').append(ts);
        });

    }

    //滚动加载
    $(window).scroll(function () {

        if(A_obj.page < A_obj.per){

            var scrollTop = $(this).scrollTop();
            var scrollHeight = $(document).height();
            var windowHeight = $(this).height();

            if (scrollTop + windowHeight == scrollHeight ) {

                A_obj.page++;
                $.post(url,A_obj,call);

            }
        }
    });

    function jup(_t) {
        location.href = '{:url("lendRecUI")}?id='+$(_t).attr('did');
    }

    function ver(ev,_t) {

        let did = $(_t).attr('did');

        layer.confirm('确认审核该出借单吗?', {icon: 3, title:'提示',shadeClose:true}, function(index){

            $.post('{:url("misc/toolsConf")}',{id:did},function (res) {
                if(res.code==1){
                    layer.msg(res.msg,{icon:6,shade:0.1},function () {
                        location.href = "{:url('leadUI')}"+"?t";
                    });
                }else{
                    layer.msg(res.msg,{icon:5});
                }
            });

            layer.close(index);
        });

        let oEvent = ev || event;
        oEvent.cancelBubble = true;
    }

</script>
</body>

</html>